home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
4dostool
/
4dtip2.zip
/
DO.DOC
< prev
next >
Wrap
Text File
|
1992-07-06
|
13KB
|
515 lines
(Original documentation by Ray Tackett)
The key to this batch file are the labels. For example, there is a label
"chkdsk". There is an alias "chdkdsk" which equals "do chkdsk". The first
thing DO.BTM does is branch to the label defined in its first argument.
Thus, typing "chkdsk" on the command line expands to "do chkdsk" which
causes this batch file to branch to the "chkdsk" label.
Having all the little batch files concentrated like this simplifies
maintenance, saves disk space (waste part of one cluster instead of many),
and allows the use of common subroutines.
@ECHO off
if "%1" == "" goto help
^^^^^ That's the trick !
goto %1
quit
REM ───────────────────────────────────────────────── Help
:help
echo.
echo Usage: DO function [options]
echo.
echo where function stands for
echo.
echo fullback - Full Backup
echo incrback - Incremental Backup
echo rest - Restore
echo.
echo chkdsk - Check disk
echo vircheck - run virus checker (f-prot)
echo.
echo normal - Reset to 4DOS environment
echo.
echo ho - Set home directory / change to home directory
echo.
echo hack - NetHack
echo info - shows some system information
echo.
quit
REM ───────────────────────────────────────────────── Disk oriented routines
"fullback" makes a full backup of the hardisk.
REM ------------------------------------------------- Full Backup
:fullback
setlocal
unalias *
set fg=%_fg
set bg=%_bg
save foreground and background color.
gosub GetDrive
returns drive letter in %DRIVE%
color bright white on black
echo Full Backup of Drive %DRIVE% named %@LABEL[%DRIVE%].
color %fg on %bg
cd \
gosub CleanUp
deletes *.BAK files and temporary swap files etc.
gosub DoVirCheck /quick
make a virus check before backuping.
:retry
del /q \backup.log
C:\DOS\backup %DRIVE% A: /s /l
make the backup
set job=Backup
gosub ReportSuccess
and report whether it was successful.
if %YesNo% == Y GOTO retry
endlocal
quit
REM ------------------------------------------------- Incremental Backup
The same game with an incremental backup...
:incrback
setlocal
unalias *
set fg=%_fg
set bg=%_bg
save foreground and background color.
gosub GetDrive
returns drive letter in %DRIVE%
color bright white on black
echo Incremental Backup of Drive %DRIVE% named %@LABEL[%DRIVE%].
color %fg on %bg
gosub CleanUp
deletes *.BAK files and temporary swap files etc.
gosub DoVirCheck /quick
make a virus check before backuping.
C:\TOOLS\newfiles /tot %DRIVE%
list new files and files that have been changed since last backup and
summarize their size. The idea is to get an impression how many disks
this backup will fill.
(You could use "dir %DRIVE%\ /kma:a..." if you don't have newfiles
or equivalent.)
:retry
C:\DOS\backup %DRIVE% A: /m /s /a /l
do the job
set job=Backup
gosub ReportSuccess
and report its success.
if %YesNo% == Y GOTO retry
endlocal
quit
REM ------------------------------------------------- Restore
Restores a single file or a directory.
:rest
setlocal
unalias *
set fg=%_fg
set bg=%_bg
gosub GetDrive
set DIRNAME=%@SUBSTR[%@FULL[%2],2,255]
set DIR=%@UPPER[%@PATH[%DIRNAME%]]
iff %@INDEX[%2,*] GE 0 .OR. %@INDEX[%2,?] GE 0 THEN
set ISAMBIG=Y
else
set ISAMBIG=N
endiff
Get Directory name and/or file name(s).
color bright white on black
echo Restoring %DRIVE%%DIRNAME%...
color %fg on %bg
iff %ISAMBIG%==Y then find /I "%DIR%" %DRIVE%\backup.log|more.com
else find /I "%DIRNAME%" %DRIVE%\backup.log|more.com
endiff
and show the disk number(s) on which they have been stored.
color bright white on black
echo Please insert appropriate disk.
color %fg on %bg
iff %ISAMBIG%=Y then C:\DOS\restore A: %DRIVE%%DIRNAME% /s /p
else C:\DOS\restore A: %DRIVE%%DIRNAME% /p
endiff
restore the files..
set job=Restore
gosub ReportSuccess
..and report the success.
endlocal
quit
The only use of this shortcut is to avoid typing a "N" when
lost clusters are detected.
REM ------------------------------------------------- CHKDSK
:chkdsk
gosub DoChkDsk
quit
Perform a virus check (by using F-PROT)
REM ------------------------------------------------- Virus Check
:vircheck
setlocal
unalias *
set fg=%_fg
set bg=%_bg
gosub GetDrive
gosub DoVirCheck
endlocal
quit
REM ─────────────────────────────────────────── Environment oriented routines
Restore the normal configuration
REM ------------------------------------------------- Normal Environment
:normal
unset *
set /r C:\4DOS\environ
alias /r C:\4DOS\aliases
echo 4DOS-Configuration read.
quit
Back to the home directory...
REM ------------------------------------------------- Home
:ho
iff "%2" == "" then
echos Changing to %@upper[%home%]...
cdd %home%
else
setlocal
*set home=%@upper[%@full[%2]]
*unset /q tmp temp cmdline comspec
iff %@index[%@upper[%path],G:\] GE 0 then
*set path=%@substr[%path,4,255]
endiff
echo New Home directory will be: %home%.
*set > c:\4DOS\environ.
endlocal
*set /r C:\4DOS\environ.
endiff
quit
REM ─────────────────────────────────────────────────────────── Applications
This "batch" file starts nethack.
REM ------------------------------------------------- NetHack
:hack
setlocal
unalias *
iff "%2"=="" then C:\NETHACK\nhack
else
iff "%4" == "c" then set term=ibmpc
elseiff "%4" == "m" then set term=ibmpc-mono
else
inkey /K"CM" /W5 [C]olor or [M]ono ? %%ask
set ask=%@UPPER[%ask]
iff "%ask" == "C" then set term=ibmpc
else set term=ibmpc-mono
endiff
endiff
IFF %@READY[G:] == 1 THEN
ECHO Installing NetHack on RamDisk G:
cdd g:\
except (4*.* acd.*) del /sxy G:\*.* >& NUL:
*md SAVE
cdd c:\NETHACK
set size=%@FILESIZE[C:\NETHACK\SAVE\SAVE2\%2.SAV,K]
iff "%size" GT "300" then
copy /q normhack.cnf nethack.cnf
set hackmode=0
elseiff "%size" GT "200" then
copy /q halfhack.cnf nethack.cnf
set hackmode=50
else
copy /q fullhack.cnf nethack.cnf
set hackmode=100
endiff
ELSE
copy /q normhack.cnf nethack.cnf
set hackmode=0
ENDIFF
:restore
iff %hackmode=0 then
copy /q C:\NETHACK\SAVE\SAVE2\%2.SAV C:\NETHACK\SAVE
elseiff %hackmode=50 then
copy /q halfhack.cnf nethack.cnf
copy /q C:\NETHACK\SAVE\SAVE2\%2.SAV C:\NETHACK\SAVE
else
copy /q fullhack.cnf nethack.cnf
copy /q C:\NETHACK\SAVE\SAVE2\%2.sav G:\SAVE
endiff
:goon
C:\NETHACK\nhack %2-%3
iff %hackmode% GT 50 then move /q G:\SAVE\%2.sav C:\NETHACK\SAVE\SAVE2
else move /q C:\NETHACK\SAVE\%2.sav C:\NETHACK\SAVE\SAVE2
endiff
inkey /K"YN " /W5 Try again (Y/N) ? %%ask
set ask=%@UPPER[%ask]
iff "%ask" == "Y" .OR. "%ask" == " " then goto /I restore endiff
echo.
endiff
endlocal
quit
REM ─────────────────────────────────────────────────────────── Jokes
I have wrote this fragment to get an impression how to use 4DOS's
built-in functions.
:info
setlocal
set alias=%_alias
unalias *
set fg=%_fg
set bg=%_bg
cls
drawbox 0 0 %@eval[%_ROWS-1] %@eval[%_COLUMNS-1] 0 white on Cyan fill Cyan
vscrput 10 0 black on white 4DOS INFO
vscrput 10 %@eval[%_COLUMNS-1] black on white 4DOS INFO
drawbox 2 2 8 46 1 black on white fill white shadow
color black on white
screen 2 15 [Environment]
screen 3 3 You are running
scrput 3 19 red on white 4DOS %_4VER
screen 3 28 under
scrput 3 34 red on white %_DOS %_DOSVER
screen 3 42 .
screen 5 3 Free Environment Space : %_ENV Bytes
screen 6 3 Free Alias Space : %ALIAS Bytes
iff %_ANSI == 0 then screen 7 3 ANSI.SYS not installed.
elseiff %_ANSI == 1 then screen 7 3 ANSI.SYS will be supported.
endiff
drawbox 2 49 8 75 1 bright yellow on green fill green shadow
color bright yellow on green
screen 2 59 [Hardware]
screen 3 50 CPU :
scrput 3 63 bright white on green %_CPU
screen 4 50 Coprocessor:
scrput 4 63 bright